package kr.haggenna.item.dao;

import java.util.List;
import java.util.Map;

import kr.haggenna.board.domain.BoardCommand;
import kr.haggenna.item.domain.Purchase;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

@Component
public class PurchaseDaoImpl extends SqlSessionDaoSupport implements PurchaseDao{
	
	@Override
	public void insertPurchase(Purchase purchase) {
		getSqlSession().insert("insertPurchase", purchase);
	}
	
	@Override
	public Purchase getRecentPurchase(Purchase purchase) {
		Purchase addPurchase = getSqlSession().selectOne("getRecentPurchase", purchase);
		return addPurchase;
	}
	
	@Override
	public List<Purchase> getPurchaseListByEmail(String email) {
		List<Purchase> purchaseList = getSqlSession().selectList("getPurchaseListByEmail", email);
		return purchaseList;
	}
	
	@Override
	public int getRowCount() {
		return getSqlSession().selectOne("getPurchaseCount");
	}
	
	@Override
	public List<Purchase> getList(Map<String, Object> map) {
		List<Purchase> list = getSqlSession().selectList("getPurchaseList",map);
		return list;
	}
	
	@Override
	public void updatePurchaseMileage(Purchase purchase) {
		getSqlSession().update("updatePurchaseMileage", purchase);
	}
	
	@Override
	public Purchase getPurchaseByNum(int pur_num) {
		Purchase purchase = getSqlSession().selectOne("getPurchaseByNum", pur_num);
		return purchase;
	}
}
